package com.tanhua.model.vo;

import com.tanhua.model.domain.UserInfo;
import com.tanhua.model.mongo.Sound;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class SoundVo {
    private Integer id; //用户id
    private String avatar; //头像
    private String nickname; //昵称
    private String gender; //性别 man woman
    private Integer age; //年龄
    private String soundUrl; //语音地址
    private Integer remainingTimes = 10; //剩余次数 -->从Redis获取

    public static SoundVo init(UserInfo userInfo, Sound sound) {
        SoundVo vo = new SoundVo();
        //copy用户属性
        BeanUtils.copyProperties(userInfo, vo);
        //copy视频属性
        BeanUtils.copyProperties(sound, vo);
        vo.setId(sound.getUserId().intValue());
        vo.setSoundUrl(sound.getSoundUrl());
        return vo;
    }
}
